/**
 * 
 */
package com.dhcc.android.base.common.view;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**
 * 
 * @author pengling
 * @date 2014-9-16
 */
public class MyViewPager extends ViewPager {

	private boolean isCanScroll = true;

	public MyViewPager(Context context) {
		super(context);
	}

	public MyViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public void setScanScroll(boolean isCanScroll) {
		this.isCanScroll = isCanScroll;
	}

	@Override
	public void scrollTo(int x, int y) {
		// if (isCanScroll){
		super.scrollTo(x, y);
		// }
	}

	@Override
	public boolean onTouchEvent(MotionEvent arg0) {
		/* return false;//super.onTouchEvent(arg0); */
		if (isCanScroll) {
			return super.onTouchEvent(arg0);
		}
		return false;
	}

	@Override
	public boolean onInterceptTouchEvent(MotionEvent event) {
		if (isCanScroll) {
			return super.onInterceptTouchEvent(event);
		}

		return false;
	}
}